const formatFormConfigs = formConfigs => {
  if (!formConfigs) return []
  return formConfigs.map(config => {
    let rules = []
    config.required &&
      rules.push({
        required: config.required,
        message: config.placeholder || undefined
      })
    return {
      type: config.type,
      formItemProps: {
        label: config.label,
        name: config.field,
        rules
      },
      props: {
        mode: config.mode,
        placeholder: config.placeholder,
        options: config.options
      }
    }
  })
}

export { formatFormConfigs }
